﻿using System;
using System.Collections.Generic;
using System.Text;
using Slippor.Douban.Radio.Share;
using Slippor.Douban.Radio.Assist;

namespace Slippor.Douban.Radio.BaseForm
{
    class DoubanRadioShareSevice : IShareService
    {
        private readonly Dictionary<String, ISharer> _sharers;
        private readonly IShareContainer _shareContainer;

        public DoubanRadioShareSevice(IShareContainer shareContainer)
        {
            _sharers = new Dictionary<String, ISharer>();
            _shareContainer = shareContainer;
        }

        #region IHandlerService Members

        public Dictionary<String, ISharer> Shares
        {
            get { return _sharers; }
        }

        public void AddShare(ISharer sharer)
        {
            Shares.Add(sharer.Name, sharer);
            _shareContainer.Add(sharer);
        }

        public void RemoveShare(ISharer sharer)
        {
            Shares.Remove(sharer.Name);
            _shareContainer.Remove(sharer);
        }

        public string Name
        {
            get { throw new NotImplementedException(); }
        }

        public void Share(Song song)
        {
            foreach (ISharer sharer in _sharers.Values)
            {
                sharer.Share();
            }
        }
        #endregion
    }
}
